﻿CREATE VIEW [acms].[UserRole_View]
AS 
	SELECT
		a.UserId,
		b.Username, 
		b.FirstName, 
		b.LastName,
		a.RoleId, 
		c.Name as RoleName, 
		a.StartDate, 
		a.EndDate, 
		a.Status,
		a.SiteId,
		d.Name as SiteName,
		a.ConcurencyId
	FROM [acms].[UserRoles] a
		inner join [acms].[Users] b on a.UserId = b.Id
		inner join [acms].[Roles] c on a.RoleId = c.Id
		inner join [acms].[Sites] d on a.SiteId = d.Id
	where b.Deleted = 0 and c.Deleted = 0 and d.Deleted = 0
;